package cn.backpackerxl.service.impl;

import cn.backpackerxl.dao.AdminDao;
import cn.backpackerxl.easyJDBC.main.EasyJDBCRepository;
import cn.backpackerxl.easyJDBC.util.PageBean;
import cn.backpackerxl.entity.Admin;
import cn.backpackerxl.service.AdminService;

import java.util.List;


/**
 * @author: backpackerxl
 * @create: 2021/12/24
 * @filename: AdminServiceImpl
 **/

public class AdminServiceImpl implements AdminService {

    private final AdminDao adminDao = (AdminDao) new EasyJDBCRepository(AdminDao.class).init();

    @Override
    public int save(Admin admin) {
        return adminDao.save(admin);
    }

    @Override
    public int update(Admin admin) {
        return adminDao.update(admin);
    }

    @Override
    public int remove(Long id) {
        return adminDao.remove(id);
    }

    @Override
    public Admin findById(Long id) {
        return adminDao.findById(id);
    }

    @Override
    public List<Admin> findAll() {
        return adminDao.findAll();
    }

    @Override
    public Admin findByNameAndPasswd(String name, String passwd) {
        return adminDao.findByOneAndOther(name, passwd);
    }

    @Override
    public List<Admin> findByNameOrPasswd(String name, String passwd) {
        return adminDao.findByOneOrOther(name, passwd);
    }

    @Override
    public List<Admin> findByName(String one) {
        return adminDao.findByOne(one);
    }

    @Override
    public PageBean<Admin> searchByName(String key, int pageSize, int currentPage) {
        return adminDao.search(key, pageSize, currentPage);
    }

    @Override
    public PageBean<Admin> pageEntityAll(int pageSize, int currentPage) {
        return adminDao.pageEntityAll(pageSize, currentPage);
    }

    @Override
    public List<Admin> searchByName(String key) {
        return adminDao.search(key);
    }

}
